package com.example.demo.controller;

import com.example.demo.service.LdapSelectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 查询所有子元素(一级)
 *
 * @author: YZD
 * @Date: 2020-04-29 20:08
 */
@RestController
public class SelectController {

    @Autowired
    private LdapSelectService ldapSelectService;

    @Value("${spring.ldap.base}")
    private String base;
    /**
     * 查询所有子元素(一级)
     *
     * @param rdn 相对路径，如"cn=Manager"或"ou=Group"
     * @return 子数组
     */
    @RequestMapping(value = "/ldapSelect")
    public List<String> ldapSelect(@RequestParam(name = "rdn", required = false, defaultValue = "ou=group") String rdn) {

        return ldapSelectService.findChild(rdn);
    }

}
